<template>
    <div class="bet-summary">
        <div class="bet-summary-cards">
            <div
                class="bet-summary-card-wrapper"
                v-for="(val, key) in betSummary"
                :key="key"
                :style="{ width: getCardWidth() }"
            >
                <div class="bet-summary-card" :style="getCardStyle(key, val)">
                    <div class="bet-desc">{{ getLabel(key) }}</div>
                    <div class="bet-summary-card-bottom">
                        <div class="bet-percent">{{ val.percent }}%</div>
                        <div class="bet-combos">
                            <span>{{ val.combos }}</span>
                            <span>combos</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="bet-summary-bar">
            <div
                class="bet-summary-bar-item"
                v-for="(val, key) in betSummary"
                :key="key"
                :style="getBarStyle(key, val)"
            ></div>
        </div>
    </div>
</template>

<script>
import { getRenderColor, getBetDesc } from "@/utils/poker/poker-config";
export default {
    name: "BetSummary",
    props: {
        betSummary:{
            type:Object
        }
    },
    methods: {
        getCardStyle(key, val) {
            return {
                background: getRenderColor(key),
            };
        },

        getCardWidth() {
            let betCounts = Object.keys(this.betSummary).length;
            let lineItemCount = Math.ceil(betCounts / 2);
            return `${100 / lineItemCount}%`;
        },

        getBarStyle(key, val) {
            return {
                background: getRenderColor(key),
                width: `${val.percent}%`,
            };
        },

        getLabel(label) {
            let desc = getBetDesc(label);
            return desc ? desc : label;
        },
    },
};
</script>

<style lang="scss">
.bet-summary {
    width: 100%;
    display: flex;
    flex-direction: column;

    .bet-summary-cards {
        width: 100%;
        height: 120px;
        margin-bottom: 5px;

        .bet-summary-card-wrapper {
            height: 50%;
            display: inline-block;
            padding: 1px;
            box-sizing: border-box;

            .bet-summary-card {
                width: 100%;
                height: 100%;
                border-radius: 4px;
                padding: 3px;
                box-sizing: border-box;

                .bet-desc {
                    color: #fff;
                    font-size: 16px;
                }

                .bet-summary-card-bottom {
                    display: flex;
                    justify-content: space-between;
                    align-items: flex-end;

                    .bet-percent {
                        color: #fff;
                        font-size: 15px;
                    }

                    .bet-combos {
                        color: #fff;
                        font-size: 12px;
                        display: flex;
                        flex-direction: column;
                        align-items: flex-end;
                    }
                }
            }
        }
    }

    .bet-summary-bar {
        width: 100%;
        height: 20px;
        border-radius: 8px;
        overflow: hidden;
        display: flex;

        .bet-summary-bar-item {
            height: 100%;
        }
    }
}
</style>
